<?php
    $result = mysqli_connect('localhost','root','root');
    if(!$result){
        echo "数据库连接失败";
    }
    mysqli_query($result,"set names 'utf8'");
    $select_db = mysqli_select_db($result,"lam");
    if(!$select_db){
        echo "不能连接到此数据库:\n".mysqli_error();
    }

    $id = $_GET['id'];
    if(isset($id)){
        $sql = "delete from guestbook where id=$id";
        $re = mysqli_query($result,$sql);
        if($re){
            echo "<script>alert('删除成功！');location.href='lam_print.php';</script>";
        }else{
            echo "<script>alert('删除失败！');location.href='lam_print.php';</script>";
        }
    }
?>